package com.lapelittle.order.service;

import com.lapelittle.framework.model.page.PageRequest;
import com.lapelittle.framework.model.page.PageResult;
import com.lapelittle.order.entity.AfterSaleOrder;
import com.lapelittle.order.mapper.AfterSaleOrderMapper;
import com.lapelittle.order.query.AfterSaleOrderQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AfterSaleOrderService {
    
    @Autowired
    private AfterSaleOrderMapper orderMapper;
    
    public PageResult<AfterSaleOrder> queryPage(AfterSaleOrderQuery query) {
        // 查询总数
        Long total = orderMapper.queryCount(query);
        
        // 查询列表
        List<AfterSaleOrder> list = orderMapper.queryList(query);
        PageRequest pageRequest = new PageRequest();
        pageRequest.setPageNum(query.getPageNum());
        pageRequest.setPageSize(query.getPageSize());
        
        // 返回分页结果
        return new PageResult<>(pageRequest, total, list);
    }
    
    public List<AfterSaleOrder> queryList(AfterSaleOrderQuery query) {
        return orderMapper.queryList(query);
    }
} 